package com.gtp.mq.demo.exchange_type.direct;

import org.apache.commons.lang.SerializationUtils;
import org.junit.Test;

import com.gtp.mq.demo.QueueBindFactory;
import com.rabbitmq.client.MessageProperties;

/*
 * 按照订阅主题
 */
public class DirectProducer extends QueueBindFactory{
	
	@Test
	public void test1() throws Exception {

		//发消息
		for(int i=0;i<100;i++){
			//资源不足(磁盘)时可能阻塞调用(异步的)
			//channel.getNextPublishSeqNo();//confirm mode下，返回消息序列号
			channel.basicPublish("mydirectExchange", 
					"r.3", 
					true,
					MessageProperties.PERSISTENT_TEXT_PLAIN,
					SerializationUtils.serialize("mgs_"+i));
		}

		System.in.read();
		
		channel.close();
	}

}
